package com.mall.common.exceptions;

import com.mall.common.responses.ServerResponse;
import com.mall.common.responses.ServerResponseEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class DefaultException{

    private static final Logger logger = LoggerFactory.getLogger(DefaultException.class);


    @ExceptionHandler(value = ShopException.class)
    public ServerResponse Exception(ShopException e){
       ServerResponse response = new ServerResponse();
       response.setCode(e.getCode());
       response.setMsg(e.getMessage());
       logger.error(e.getMessage());
       return response;
    }


}
